package com.openflag.bwicservice.repository;

import com.openflag.bwicservice.domain.Bid;
import com.openflag.bwicservice.domain.Bwic;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface BidRepository extends JpaRepository<Bid,Long> {
    @Query(value = "select client_id from bid where bwic_id = ?1 " +
            "and bid_market_value = (select max(bid_market_value) from bid where bwic_id = ?1)",
            nativeQuery=true)
    Long getWinnerIdByBwicId(Long bwicId);


    @Query(value = "select bwic_id from bid where client_id = ?1",nativeQuery=true)
    List<Long> getSellerBwicIdByClientId(Long ClientId);

    @Query(value = "select * from bid where bwic_id = ?1",nativeQuery = true)
    List<Bid> getBidList(Long bwicId);

    @Query(value = "select * from bid where bwic_id = ?1 and client_id = ?2",nativeQuery = true)
    Bid getBidByBwicIdAndClientId(Long bwicId,Long clientId);



}
